#override("title")
SpringWind - 场地地图列表
#end
#override("css")
<link href="#springUrl('/static/css/plugins/bootstrap-table/bootstrap-table.min.css')" rel="stylesheet">
<style type="text/css">
    #allmap{width:100%;height:500px;}
</style>
#end
#override("breadcrumb")
<li><a>评分系统</a></li><li class="active"><strong>场地列表</strong><strong>$!{province}</strong><strong>$!{city}</strong></li>
#end
#override("content")
<div class="row">
</div>
<div class="row">
        <div id="allmap"></div>
</div>
#end
#override("js")
<script src="#springUrl('/static/js/plugins/bootstrap-table/bootstrap-table.min.js')"></script>
<script src="#springUrl('/static/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js')"></script>
<script src="#springUrl('/static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js')"></script>
<script src="#springUrl('/static/plugins/layer-v2.2/layer/layer.js')"></script>
<!--<script src="#springUrl('/static/js/base_list.js')"></script>-->
<script src="#springUrl('/static/js/common.js')"></script>
<script src="http://api.map.baidu.com/api?v=2.0&ak=2GlUhNFAKn4hBkQBkM39G303SE9XFDTc"></script>
<script type="text/javascript">
    var siteList = JSON.parse('${siteList}');
  //  var province = '${province}';
    // 百度地图API功能
    var mp = new BMap.Map("allmap");
    mp.centerAndZoom(siteList[0].province,8);
    mp.enableScrollWheelZoom(true);
    mp.disableDragging();
    setTimeout(function(){
        mp.enableDragging();   //两秒后开启拖拽
        //map.enableInertialDragging();   //两秒后开启惯性拖拽
    }, 2000);
    // 复杂的自定义覆盖物
    function ComplexCustomOverlay(point, text, mouseoverText){
        this._point = point;
        this._text = text;
        this._overText = mouseoverText;
    }
    ComplexCustomOverlay.prototype = new BMap.Overlay();
    ComplexCustomOverlay.prototype.initialize = function(map){
        this._map = map;
        var div = this._div = document.createElement("div");
        div.style.position = "absolute";
        div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
        div.style.backgroundColor = "#EE5D5B";
        div.style.border = "1px solid #BC3B3A";
        div.style.color = "white";
        div.style.height = "18px";
        div.style.padding = "2px";
        div.style.lineHeight = "18px";
        div.style.whiteSpace = "nowrap";
        div.style.MozUserSelect = "none";
        div.style.fontSize = "12px"
        var span = this._span = document.createElement("span");
        div.appendChild(span);
        span.appendChild(document.createTextNode(this._text));
        var that = this;

        var arrow = this._arrow = document.createElement("div");
        arrow.style.background = "url(http://map.baidu.com/fwmap/upload/r/map/fwmap/static/house/images/label.png) no-repeat";
        arrow.style.position = "absolute";
        arrow.style.width = "11px";
        arrow.style.height = "10px";
        arrow.style.top = "22px";
        arrow.style.left = "10px";
        arrow.style.overflow = "hidden";
        div.appendChild(arrow);

        div.onmouseover = function(){
            this.style.backgroundColor = "#6BADCA";
            this.style.borderColor = "#0000ff";
            this.getElementsByTagName("span")[0].innerHTML = that._overText;
            arrow.style.backgroundPosition = "0px -20px";
        }

        div.onmouseout = function(){
            this.style.backgroundColor = "#EE5D5B";
            this.style.borderColor = "#BC3B3A";
            this.getElementsByTagName("span")[0].innerHTML = that._text;
            arrow.style.backgroundPosition = "0px 0px";
        }

        mp.getPanes().labelPane.appendChild(div);

        return div;
    }
    ComplexCustomOverlay.prototype.draw = function(){
        var map = this._map;
        var pixel = map.pointToOverlayPixel(this._point);
        this._div.style.left = pixel.x - parseInt(this._arrow.style.left) + "px";
        this._div.style.top  = pixel.y - 30 + "px";
    }

    $(function () {
      //  initMarker("");
    });
    var txt;
    var myCompOverlay;
    for (i=0;i<siteList.length;i++){
        txt = siteList[i].province;
        if(siteList[i].dist != null){
            mouseoverTxt = txt + " "+siteList[i].city+" "+siteList[i].dist +" "+siteList[i].score;
        }else {
            mouseoverTxt = txt + " "+siteList[i].city+" "+siteList[i].score ;
        }
        myCompOverlay = new ComplexCustomOverlay(new BMap.Point(siteList[i].latitude,siteList[i].longitude), siteList[i].province+" "+siteList[i].city+" "+siteList[i].score,mouseoverTxt);
        mp.addOverlay(myCompOverlay);
    }


    //加载标注点
    /*function initMarker(id) {
        $.ajax({
            type: "get",
            url: "siteView/getSiteInList",
            dataType: "json",
            async: false,
            data: { "id": id },
            success: function (data) {
                mp.clearOverlays();
                var i = 0;
                var points = [];
                for (var item in data.siteInfo) {
                    (function (x) {
                        //创建标注
                        var pt = new BMap.Point(data.siteInfo[item].MapPointX, data.siteInfo[item].MapPointY);
                        points[i] = pt;
                        var marker = new BMap.Marker(pt);
                        map.addOverlay(marker);
                        var label = new BMap.Label(data.siteInfo[item].Name, { offset: new BMap.Size(30, -10) });
                        marker.setLabel(label);
                        label.setStyle({
                            color: "White",
                            fontSize: "14px",
                            backgroundColor: "#5CACEE",
                            border: "0"
                        });
                        //创建信息窗口
                        var opts = {
                            width: 400,     // 信息窗口宽度
                            height: 120,     // 信息窗口高度
                            title: "<strong style=\"font-size:16px;font-weight:bold\">" + data.siteInfo[item].Name + "</strong>", // 信息窗口标题
                            enableMessage: true, //设置允许信息窗发送短息
                            message: ""
                        }
                        var showInfo = "地址：" + data.siteInfo[item].Addresss + "<br/>" + "描述：" + data.siteInfo[item].BasicFacts + "<br/>指数：" + data.siteInfo[item].HouseArea + "<br/>地块个数:" + data.siteInfo[item].nurseryBlockCount;
                        var infoWindow = new BMap.InfoWindow(showInfo, opts);  // 创建信息窗口对象
                        marker.addEventListener("click", function (e) {
                            //map.centerAndZoom(pt, 12);
                            marker.openInfoWindow(infoWindow, pt); //开启信息窗口
                        });
                        map.addOverlay(marker);
                        i++;
                    })(i);
                }

                if (id == "") {
                    mp.setViewport(points);
                } else {
                    map.setViewport(points);
                    setTimeout(function () {
                        map.setZoom(14);
                    }, 100);  //0.1秒后放大到14级
                }

            },
            error: function (error) {
                alert("加载失败，请检查网络或其他原因");
            }
        });
    }*/
</script>
#end
#extends("/common/framework.html")
